<!-- $Id:filter_order liuricheng 2014-08-05 -->
<style>
.qs-alert{padding:2px;color:#404040;}
</style>
<div class="alert alert-success qs-alert">
	<form action="javascript:searchOrder()" name="searchForm">
		<img src="__PUBLIC__/image/admin/icon_search.gif" width="26" height="22" border="0" alt="SEARCH">
		订单号<input name="order_sn" type="text" id="order_sn" size="15">
		收货人<input name="consignee" type="text" id="consignee" size="15">
		订单状态    
		<select name="status" id="status">
			<option value="-1">请选择...</option>
			<volist name="orderStatusList" id="orderStatus">
			<option value="{$key}" selected="">{$orderStatus}</option>
			</volist>
		</select>
		<input type="submit" class="btn btn-default" style="background:#5CB85C;color:#fff;"  value=" 搜索 " />
		<a href="order.php?act=list&amp;composite_status=0">待确认</a>
		<a href="order.php?act=list&amp;composite_status=100">待付款</a>
		<a href="order.php?act=list&amp;composite_status=101">待发货</a>
	</form>
</div>
<script language="javascript">
	
	listTable.recordCount = 19;
	listTable.pageCount = 2;

	listTable.filter.order_sn = '';
	listTable.filter.consignee = '';
	listTable.filter.email = '';
	listTable.filter.address = '';
	listTable.filter.zipcode = '';
	listTable.filter.tel = '';
	listTable.filter.mobile = '0';
	listTable.filter.country = '0';
	listTable.filter.province = '0';
	listTable.filter.city = '0';
	listTable.filter.district = '0';
	listTable.filter.shipping_id = '0';
	listTable.filter.pay_id = '0';
	listTable.filter.order_status = '-1';
	listTable.filter.shipping_status = '-1';
	listTable.filter.pay_status = '-1';
	listTable.filter.user_id = '0';
	listTable.filter.user_name = '';
	listTable.filter.composite_status = '-1';
	listTable.filter.group_buy_id = '0';
	listTable.filter.sort_by = 'add_time';
	listTable.filter.sort_order = 'DESC';
	listTable.filter.start_time = '';
	listTable.filter.end_time = '';
	listTable.filter.page = '1';
	listTable.filter.page_size = '15';
	listTable.filter.record_count = '19';
	listTable.filter.page_count = '2';
	
	/**
	 * 载入列表
	 */
	listTable.loadList = function()
	{
	   //add code 
		$.ajax({
			url:'__URL__/order_list'
		});
	   
	}
	

	onload = function()
	{
		// 开始检查订单
		//startCheckOrder();
	}

	/**
	 * 搜索订单
	 */
	function searchOrder()
	{
		alert(56);
		listTable.filter['order_sn'] = Utils.trim(document.forms['searchForm'].elements['order_sn'].value);
		listTable.filter['consignee'] = Utils.trim(document.forms['searchForm'].elements['consignee'].value);
		listTable.filter['composite_status'] = document.forms['searchForm'].elements['status'].value;
		listTable.filter['page'] = 1;
		listTable.loadList();
	}

	function check()
	{
	  var snArray = new Array();
	  var eles = document.forms['listForm'].elements;
	  for (var i=0; i<eles.length; i++)
	  {
		if (eles[i].tagName == 'INPUT' && eles[i].type == 'checkbox' && eles[i].checked && eles[i].value != 'on')
		{
		  snArray.push(eles[i].value);
		}
	  }
	  if (snArray.length == 0)
	  {
		return false;
	  }
	  else
	  {
		eles['order_id'].value = snArray.toString();
		return true;
	  }
	}
	/**
	 * 显示订单商品及缩图
	 */
	var show_goods_layer = 'order_goods_layer';
	var goods_hash_table = new Object;
	var timer = new Object;

	/**
	 * 绑定订单号事件
	 *
	 * @return void
	 */
	function bind_order_event()
	{
		var order_seq = 0;
		while(true)
		{
			var order_sn = Utils.$('order_'+order_seq);
			if (order_sn)
			{
				order_sn.onmouseover = function(e)
				{
					try
					{
						window.clearTimeout(timer);
					}
					catch(e)
					{
					}
					var order_id = Utils.request(this.href, 'order_id');
					show_order_goods(e, order_id, show_goods_layer);
				}
				order_sn.onmouseout = function(e)
				{
					hide_order_goods(show_goods_layer)
				}
				order_seq++;
			}
			else
			{
				break;
			}
		}
	}
	listTable.listCallback = function(result, txt) 
	{
		if (result.error > 0) 
		{
			alert(result.message);
		}
		else 
		{
			try 
			{
				document.getElementById('listDiv').innerHTML = result.content;
				bind_order_event();
				if (typeof result.filter == "object") 
				{
					listTable.filter = result.filter;
				}
				listTable.pageCount = result.page_count;
			}
			catch(e)
			{
				alert(e.message);
			}
		}
	}
	/**
	 * 浏览器兼容式绑定Onload事件
	 *
	 */
	if (Browser.isIE)
	{
		window.attachEvent("onload", bind_order_event);
	}
	else
	{
		window.addEventListener("load", bind_order_event, false);
	}

	/**
	 * 建立订单商品显示层
	 *
	 * @return void
	 */
	function create_goods_layer(id)
	{
		if (!Utils.$(id))
		{
			var n_div = document.createElement('DIV');
			n_div.id = id;
			n_div.className = 'order-goods';
			document.body.appendChild(n_div);
			Utils.$(id).onmouseover = function()
			{
				window.clearTimeout(window.timer);
			}
			Utils.$(id).onmouseout = function()
			{
				hide_order_goods(id);
			}
		}
		else
		{
			Utils.$(id).style.display = '';
		}
	}

	/**
	 * 显示订单商品数据
	 *
	 * @return void
	 */
	function show_order_goods(e, order_id, layer_id)
	{
		create_goods_layer(layer_id);
		$layer_id = Utils.$(layer_id);
		$layer_id.style.top = (Utils.y(e) + 12) + 'px';
		$layer_id.style.left = (Utils.x(e) + 12) + 'px';
		if (typeof(goods_hash_table[order_id]) == 'object')
		{
			response_goods_info(goods_hash_table[order_id]);
		}
		else
		{
			$layer_id.innerHTML = loading;
			Ajax.call('order.php?is_ajax=1&act=get_goods_info&order_id='+order_id, '', response_goods_info , 'POST', 'JSON');
		}
	}

	/**
	 * 隐藏订单商品
	 *
	 * @return void
	 */
	function hide_order_goods(layer_id)
	{
		$layer_id = Utils.$(layer_id);
		window.timer = window.setTimeout('$layer_id.style.display = "none"', 500);
	}

	/**
	 * 处理订单商品的Callback
	 *
	 * @return void
	 */
	function response_goods_info(result)
	{
		if (result.error > 0)
		{
			alert(result.message);
			hide_order_goods(show_goods_layer);
			return;
		}
		if (typeof(goods_hash_table[result.content[0].order_id]) == 'undefined')
		{
			goods_hash_table[result.content[0].order_id] = result;
		}
		Utils.$(show_goods_layer).innerHTML = result.content[0].str;
	}



</script>